package com.tl.libpay.network;


import com.tl.commonlibrary.network.BaseNet;
import com.tl.commonlibrary.network.NetManager;
import com.tl.commonlibrary.network.RequestCallBack;
import com.tl.commonlibrary.network.RequestListener;
import com.tl.commonlibrary.network.bean.base.BaseBean;
import com.tl.commonlibrary.ui.beans.ABCPayBean;
import com.tl.commonlibrary.ui.beans.ABCPayResultBean;
import com.tl.commonlibrary.ui.beans.AliPayBean;
import com.tl.commonlibrary.ui.beans.AliPayResultBean;
import com.tl.commonlibrary.ui.beans.WxPayOrderInfoBean;

import java.util.HashMap;

import retrofit2.Call;

/**
 * Created by Administrator on 2017/6/2 0002.
 * 接口请求
 */

public class Net extends BaseNet {
    private static CommonInterfaceService service = NetManager.get().create(CommonInterfaceService.class);

    /**
     */
    public static Call aliPay(String productId, RequestListener<BaseBean<AliPayBean>> listener) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("productId", productId);
//        map.put("sandbox","1");
        Call<BaseBean<AliPayBean>> call = service.aliPay(getBody(map));
        call.enqueue(new RequestCallBack<>(listener));
        return call;
    }

    /**
     * @param tradeNo 订单
     */
    public static Call aliPayResult(String tradeNo, RequestListener<BaseBean<AliPayResultBean>> listener) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("orderNo", tradeNo);
        Call<BaseBean<AliPayResultBean>> call = service.aliPayResult(getBody(map));
        call.enqueue(new RequestCallBack<>(listener));
        return call;
    }


    public static Call wechatPay(String productId, RequestListener<BaseBean<WxPayOrderInfoBean>> listener) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("productId", productId);
        Call<BaseBean<WxPayOrderInfoBean>> call = service.wechatPay(getBody(map));
        call.enqueue(new RequestCallBack<>(listener));
        return call;
    }

    //微信支付完成后,到本地服务器查询订单
    public static Call wechatPayResult(int payType, String tradeNo, RequestListener<BaseBean> listener) {
//        HashMap<String, String> map = new HashMap<>();
//        map.put("payType", String.valueOf(payType));
//        map.put("tradeNo", tradeNo);
//        Call<BaseBean> call = service.wechatOrderInfo(getDataParam(map));
//        call.enqueue(new RequestCallBack<>(listener).foreground(false));
//        return call;
        return null;
    }

    public static Call abcPay(HashMap<String, Object> map, RequestListener<BaseBean<ABCPayBean>> listener) {
//        Call<BaseBean<ABCPayBean>> call = service.abcPay(getDataParam(map));
//        call.enqueue(new RequestCallBack<>(listener));
//        return call;
        return null;
    }

    /**
     * @param tradeNo 订单
     */
    public static Call abcPayResult(String tradeNo, RequestListener<BaseBean<ABCPayResultBean>> listener) {
//        HashMap<String, String> map = new HashMap<>();
//        map.put("tradeNo", tradeNo);
//        Call<BaseBean<ABCPayResultBean>> call = service.abcPayResult(getDataParam(map));
//        call.enqueue(new RequestCallBack<>(listener).foreground(false));
//        return call;
        return null;
    }

    public static void onDestroy() {
        service = null;
    }


}
